<template>
  <div class="nav">
    <div class="back" @click="goPage()"><x-icon  v-if="notback" type="ios-arrow-left"></x-icon></div>
    
    <h1 class="title">{{ title }}</h1>
    <div class="create">
      <router-link v-if="isAdd" :to="whereIs">
        <img src="../image/u16.png" alt="">
        <span class="text">新建</span>
      </router-link>
      <!-- <img src="../image/mod-icon.png"> -->
    </div>
  </div>
</template>

<script>
  export default {
    name: 'nav-title',
    props: {
      title: {
        type: String,
        default: ''
      },
      routerLink: {
        type: String,
        routerLink: ''
      },
      whereIs: {
        type: String,
        default: ''
      },
      isAdd: {
        type: Boolean,
        default: false
      },
      notback: {
        type: Boolean,
        default: true
      }
    },
    methods: {
      goPage(){
        if(this.routerLink && this.routerLink != ''){
          this.$router.push({
            name: this.routerLink
          })
        }else{
          this.$router.go(-1);
        }
      }
    }
  }
</script>

<style type="text/scss" lang="scss" scoped>
  .nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 50px;
    margin-bottom: 10px;
    .back {
      font-size: 30px;
      font-weight: 500;
      flex: 1;
      text-align: left;
      margin-left: 20px;
    }
    .title {
      flex: 3;
      font-size: 20px;
      font-weight: 900;
      color: #333333;
    }
    .create {
      flex: 1;
      display: flex;
      justify-content: flex-end;
      align-items: flex-start;
      margin-right: 20px;
      img {
        width: 20px;
        height: 20px;
      }
      .text {
        vertical-align: super;
        font-size: 14px;
        color: #07BC4B;
      }
    }
  }

</style>
